import pdfplumber
import os

def transform_pdf_to_txt(target_file_path, result_file_path):
	if not target_file_path.endswith(".pdf"):
		raise Exception("无效格式的文件") 
	if os.path.exists(result_file_path) == False:
		os.mknod(result_file_path)

	with pdfplumber.open(target_file_path) as pdf:
		
		with open(result_file_path,'w') as file:
			for page in pdf.pages:
				
				file.write(page.extract_text())

			file.close()
		pdf.close()


if __name__ == "__main__":
	transform_pdf_to_txt("..//material//SSE-script.pdf", "..//output//pdf_output.txt")